package com.glsc.ngateway.oaflow.exception;

import com.glsc.ngateway.oaflow.service.MailService;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.Arrays;

@Aspect
@Component
public class JobAopException {

    @Resource
    private MailService mailService;

    @Pointcut("execution(* com.glsc.ngateway.oaflow.schedule..*(..))")
    public void all()  {

    }

    @AfterThrowing(pointcut="all()", throwing="ex")
    public void afterThrowing(Exception ex)  {
        // Do what you want
        ex.printStackTrace();
        mailService.sendMailToAdmin("网关oaflow异常", Arrays.toString(ex.getStackTrace()));
    }
}
